/* 
 * 任意数求和
 * 1. 传递实参的个人不确定
 * 2. 传递的值是否为有效数字不定
 * 3. 把传递的有效数字进行相加求和
*/

function sum() {
  let total = null;
  for(let i = 0; i < arguments.length; i++) {
    let item = Number(arguments[i]);
    if(isNaN(item)) {
      continue;
    }
    total += item;
  }
  return total;
}

let total = sum(10, 20, 30, 40);
console.log(total);

total = sum(10, 20);
console.log(total);

total = sum(10, 20, '30');
console.log(total);

total = sum(10, 'AA');
console.log(total);
